<html><head><title>Use Case Diagram - Example</title>



<link rel="stylesheet" href="02day12_files/help.css">
<script language="JavaScript">
var previous = "02day11.html";
var next = "02day13.html";

function matchCont(contentsFile){
  if ((parent.left) && (parent.left.location.pathname.indexOf(contentsFile)
== -1 && parent.left.location.pathname.indexOf('help_index') == -1 &&
parent.left.location.pathname.indexOf('search') == -1)){
    parent.left.location.replace('' + contentsFile + '#1');
  }
}
function otvoriSlika()
{ var openWindow=window.open("","ucd","height=400,width=450");
  openWindow.document.write("<HTML>")
  openWindow.document.write("<TITLE>Self-Service Machine use case diagram</TITLE>")
  openWindow.document.write("<BODY><font face='Arial'>")
  openWindow.document.write("<p><img src='images/day02/SSMusecaseDiagram.gif'></p>")
  openWindow.document.write("<p><a href='' onClick='self.close()'>This closes the window</a></p>")
  openWindow.document.write("</font></BODY>")
  openWindow.document.write("</HTML>")
}
</script></head><body onload="matchCont('cont02.htm')" alink="#000000" bgcolor="#ffffff" link="#333399" vlink="#660033">

<p><a name="74281"></a></p>

<h2>Use Case Diagram - Example</h2>

<p>In this example we're going to model out use case diagrams for a self-service machine. </p>

<p>The main functions of self-service machine is to allow a customer to by a product(s)
from the machine (candy, chocolate, juice...). Every user that you asked for a set of
scenarios happening during usage of machine, can tell you that main use case can be
labeled as "Buy a product". Let's examine every possible scenario in this use
case. These scenarios would be revealed trough conversations with users.</p>

<p><strong>The "Buy a product" use case</strong></p>

<p>The actor in this use case is customer. This customer wants to buy some of the products
offered by the self-service machine. First of all he/she inserts money into the
machine, selects one or more products, and machine presents a selected product(s) to the
customer. Use case diagram for this scenario can be represented as:</p>
<div align="center"><center>

<table border="0" cellpadding="0" cellspacing="1" width="100%">
  <tbody><tr>
    <td width="230"><img src="02day12_files/usecase1.GIF" alt="usecase1" height="72" width="220"></td>
    <td valign="bottom"><font color="#808080"><em>The <strong>Buy a Product</strong> use case
    diagram</em></font></td>
  </tr>
</tbody></table>
</center></div>

<p>But if we think a little, others scenarios immediatelly come to mind. It's possible
that the self-service machine is out of one or more products, or the machine hasn't the
exact amount of money to return to customer.</p>

<p>-Are we supposed to handle with these scenarios?</p>

<p>If we are, then let's return at the moment when the customer inserts money into machine
and enters his or hers selection. After this imagine that machine is out of brand. In this
case it's preferable to present a message to the customer that machine is out of brand and
allow him or her to make another selection or return money back. If
incorrect-ammount-of-money scenario has hapenned, then self-service machine is supposed to
return original ammount of money to the customer.<br>
The precondition here is hungry or thirsty customer, and postcondition is either product
from the machine or the returned money.</p>

<p>This is use case scenario from one user's viewpoint (the customer). Buth there are
other users too. A supplier has to restock the machine, and a collector has to collect the
accumulated money from the machine. This tells us to create at least two more use
cases: "Restock" and "Collect money". Let's look closely at both of
them, by interviewing both suppliers and collectors.</p>

<p><strong>The "Restock" use case</strong></p>

<p>Actions that supplier must do every time interval (say, one or two weeks) are: Supplier
unsecures the machine, opens the front of the machine, and fills each brand's compartment
to capacity. (The supplier may fill each brand according to consuming of article). Then he/
she closes the front of the machine and secures it. <br>
The precondition is the passage of the interval, and the postcondition is that the
supplier has a new set of potential sales.<br>
This use case diagram is presented on the following picture:</p>
<div align="center"><center>

<table border="0" cellpadding="0" cellspacing="1" width="100%">
  <tbody><tr>
    <td width="224"><img src="02day12_files/usecase2.GIF" alt="usecase2" height="72" width="214"></td>
    <td valign="bottom"><font color="#808080"><em>The <strong>Restock</strong> use case
    diagram</em></font></td>
  </tr>
</tbody></table>
</center></div>

<p><strong>The "Collect Money" use case</strong></p>

<p>Responsible for this use case is collector. Collector may be the same person as the
supplier. The steps that collector must do are same as the steps of supplier, but the
collector don't deal with products, he/ she deals with money. When the time
interval has
passed this person collects the necessary ammount of money from the machine.<br>
The postcondition here is the money in hands of the collector.<br>
Collect money use case diagram is following:</p>
<div align="center"><center>

<table border="0" cellpadding="0" cellspacing="1" width="100%">
  <tbody><tr>
    <td width="227"><img src="02day12_files/usecase3.GIF" alt="usecase3" height="72" width="217"></td>
    <td valign="bottom"><font color="#808080"><em>The <strong>Collect Money</strong> use case
    diagram</em></font></td>
  </tr>
</tbody></table>
</center></div>

<p>The steps of unsecuring the machine, front opening, closing and securing the machine
are the same that supplier and collector must do. This is a good place to
include a use
case. Let's combine the "unsecure" and "pull open" steps into use case
called "Expose the inside" and the "close machine" and
"secure" with use case "Unexpose the inside".<br>
By including a use case Restock and Collect use cases may look as this:</p>
<div align="center"><center>

<table border="0" cellpadding="0" cellspacing="1" width="100%">
  <tbody><tr>
    <td width="273"><img src="02day12_files/usecase4.GIF" alt="usecase4" height="171" width="263"></td>
    <td valign="bottom"><font color="#808080"><em>The inclusion process in Restock and Collect
    Money use cases</em></font></td>
  </tr>
</tbody></table>
</center></div>

<p>The Restock use case could be basis of another use case: "Restock according to
sales". Here supplier may fill up brands with new products according of sale of that
products. This is an extension of a use case.<br>
After inclusion and extension the Restock use case can be:</p>
<div align="center"><center>

<table border="0" cellpadding="0" cellspacing="1" width="100%">
  <tbody><tr>
    <td width="336"><img src="02day12_files/usecase5.GIF" alt="usecase5" height="148" width="326"></td>
    <td valign="bottom"><font color="#808080"><em>The extension process in Restock use case</em></font></td>
  </tr>
</tbody></table>
</center></div>

<p>Also and generalization may take place to the actors supplier and collector. If both of
them are the same person, let's say Supplier Agent, then the restocker and the supplier
are both children of the Supplier Agent. This is showh on next picture:</p>
<div align="center"><center>

<table border="0" cellpadding="0" cellspacing="1" width="100%">
  <tbody><tr>
    <td width="127"><img src="02day12_files/usecase6.GIF" alt="usecase6" height="181" width="117"></td>
    <td valign="bottom"><font color="#808080"><em>A generalization between supplier and
    collector</em></font></td>
  </tr>
</tbody></table>
</center></div>

<p><a name="ovde"></a>We reached the end of our analysis for the self-service machine. <a href="#ovde" onclick="otvoriSlika()">Completed use case diagram</a> (Click for the
entirely use case diagram) shows the functional requirements of the system, and we are
able to make next move - design and development.</p>
</body></html>